package com.shigu.main4.common.util;

/**
 * 加密工具
 */
public class SecretUtil {
    /**
     * 加密银行卡
     * @param bankNumber
     * @return
     */
    public static String secretBank(String bankNumber){
        if (bankNumber.length()>8) {
            return bankNumber.substring(0,4)+" **** **** "+bankNumber.substring(bankNumber.length()-4,bankNumber.length());
        }else if(bankNumber.length()>4){
            return "******"+bankNumber.substring(bankNumber.length()-4,bankNumber.length());
        }
        return bankNumber;
    }

    /**
     * 加密名字
     * @param name
     * @return
     */
    public static String secretName(String name){
        if (name.length()>2) {
            return name.substring(0,1)+"*"+name.substring(name.length()-1,name.length());
        }else if(name.length()==2){
            return "*"+name.substring(1,2);
        }
        return name;
    }
}
